Skip to content

feat(search): implement advanced search with filters, pagination, and… - #204

Merged
ayomideadeniran merged 1 commit into
StellarDevHub:mainfrom
ekwe7:Implement-Advanced-Search-with-Filters-Pagination-and-Full-Text-Search
Apr 25, 2026
Merged

feat(search): implement advanced search with filters, pagination, and…#204
ayomideadeniran merged 1 commit into
StellarDevHub:mainfrom
ekwe7:Implement-Advanced-Search-with-Filters-Pagination-and-Full-Text-Search

Conversation

@ekwe7

@ekwe7 ekwe7 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Closes #197

Backend - Implement Advanced Search with Filters, Pagination, and Full-Text Search

Description

This PR implements a comprehensive search system for the Web3 Student Lab backend with the following features:

  • Full-text search across courses (title, description, instructor), students (name, email), and certificates
  • Advanced filtering with multiple operators (eq, neq, gt, gte, lt, lte, in, contains, startsWith)
  • Pagination support with both offset-based and cursor-based pagination
  • Multi-field sorting with ascending/descending order
  • Search result metadata including execution time and total results
  • Database indexes for optimal search performance

Key Components Added:

  1. Search Infrastructure (src/search/):

    • SearchService.ts - Base search service class
    • SearchQueryBuilder.ts - Dynamic query building for filters and search
    • SearchValidator.ts - Input validation and sanitization
    • PaginationHelper.ts - Pagination logic for both offset and cursor methods
    • FilterParser.ts - Advanced filter parsing from query strings
  2. Entity-Specific Search Services:

    • CourseSearchService.ts - Search courses with title, description, instructor
    • StudentSearchService.ts - Search students by name and email
    • CertificateSearchService.ts - Search certificates with enriched student/course data
  3. API Endpoints (src/routes/search/):

    • GET /api/search/courses - Search courses
    • GET /api/search/students - Search students
    • GET /api/search/certificates - Search certificates
    • GET /api/search/all - Global search across all entities
  4. Database Optimizations:

    • Added indexes on searchable fields for performance
    • Updated Prisma schema with proper indexing

API Usage Examples:

# Search courses with filters and pagination
GET /api/search/courses?query=soroban&filter[credits][gte]=3&sort=title:asc&page=1&limit=10

# Cursor-based pagination for certificates
GET /api/search/certificates?cursor=eyJpZCI6MTAwfQ==&limit=20

# Global search
GET /api/search/all?query=blockchain

Response Format:

{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 45,
    "hasMore": true
  },
  "metadata": {
    "query": "soroban",
    "filters": { "credits": { "gte": 3 } },
    "sortBy": "title:asc",
    "executionTime": "45ms",
    "totalResults": 45
  }
}

Reference Issues

Fixes #197 Backend - Implement Advanced Search with Filters, Pagination, and Full-Text Search

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@drips-wave

drips-wave Bot commented Apr 23, 2026

Copy link
Copy Markdown

@ekwe7 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@ayomideadeniran

Copy link
Copy Markdown
Contributor

@ekwe7 Hi, all checks must pass before I can merge the PR. Please review the failing checks, fix the issues, and update the PR once everything is passing.

@ayomideadeniran

Copy link
Copy Markdown
Contributor

Pr under review, i will get back to you if i find any wrong implementations.

@ayomideadeniran
ayomideadeniran merged commit 06bec80 into StellarDevHub:main Apr 25, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants